home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.04 Apr 91 / Jorg Code / TEDrag.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-22  |  7.9 KB  |  275 lines  |  [TEXT/MPS ]

  1.  
  2. class TTEApplication : public TApplication {
  3. public:
  4.     virtual pascal void ITEApplication(OSType itsMainFileType);
  5.     virtual pascal struct TDocument *DoMakeDocument(CmdNumber itsCmdNumber);
  6.     virtual pascal struct TCommand *DoMenuCommand(CmdNumber aCmdNumber);
  7.     virtual pascal void PoseModalDialog();
  8. #ifdef qDebug
  9.     virtual pascal void IdentifySoftware();
  10. #endif
  11. };
  12.  
  13. class TTEDocument;
  14.  
  15. class TPaletteView : public TView {
  16.  
  17. // friend class TTEDocument;
  18.  
  19. public:
  20.     int            fIconSelected;
  21.     virtual pascal void IPaletteView(TTEDocument *itsTEDocument);
  22.     virtual pascal struct TCommand *DoMouseCommand(Point *theMouse,
  23.                                 EventInfo *info, Point *hysteresis);
  24.     pascal void DoHighlightSelection(HLState fromHL, HLState toHL);
  25.     pascal void Draw(Rect *area);
  26. #ifdef qDebug
  27.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  28.                              Ptr fieldAddr, short fieldType, void *link), void *link);
  29. #endif
  30. };
  31.  
  32.  
  33. class TBox : public TObject {
  34. public:
  35.     Rect    fLocation;
  36.     Boolean    fSelected;
  37.     RgnHandle    fTagRgn;
  38.     Rect    fTL,fTR,fBL,fBR,
  39.             fT,fB,fL,fR;
  40.     virtual pascal void IBox(Rect *itsLocation);
  41.     virtual pascal void DrawShape();
  42.     virtual pascal void NeedDiskSpace(long *data);
  43.     virtual pascal void Read(short aRefNum);
  44.     virtual pascal void Write(short aRefNum);
  45. #ifdef qDebug
  46.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  47.                              Ptr fieldAddr, short fieldType, void *link), void *link);
  48. #endif
  49. };
  50.  
  51. class TShape : public TBox {
  52. public:
  53.     short    fPenSize;
  54.     Pattern    fPenPat;
  55.     Pattern    fFillPat;
  56.     virtual pascal void NeedDiskSpace(long *data);
  57.     virtual pascal void IBox(Rect *itsLocation);
  58.  
  59. #ifdef qDebug
  60.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  61.                              Ptr fieldAddr, short fieldType, void *link), void *link);
  62. #endif
  63. };
  64.  
  65. class TRect : public TShape {
  66. public:
  67.     pascal void DrawShape();
  68.     pascal void NeedDiskSpace(long *data);
  69. #ifdef qDebug
  70.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  71.                              Ptr fieldAddr, short fieldType, void *link), void *link);
  72. #endif
  73. };
  74.  
  75. class TOval : public TShape {
  76. public:
  77.     pascal void DrawShape();
  78.     pascal void NeedDiskSpace(long *data);
  79. #ifdef qDebug
  80.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  81.                              Ptr fieldAddr, short fieldType, void *link), void *link);
  82. #endif
  83. };
  84.  
  85. class TRoundRect : public TShape {
  86. public:
  87.     short    fOvalWidth;
  88.     short    fOvalHeight;
  89.     
  90.     pascal void IBox(Rect *itsLocation);
  91.     pascal void DrawShape();
  92.     pascal void NeedDiskSpace(long *data);
  93. #ifdef qDebug
  94.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  95.                              Ptr fieldAddr, short fieldType, void *link), void *link);
  96. #endif
  97. };
  98.  
  99.  
  100. class TTextView : public TTEView {
  101.  
  102. public:
  103.     TTEDocument    *fTEDocument;
  104.     TPaletteView    *fPaletteView;
  105.     Boolean            fUpdated;
  106.     pascal void ITextView(TTEDocument *itsTEDocument);
  107.     pascal Boolean DoIdle(IdlePhase phase);
  108.     pascal struct TCommand *DoKeyCommand(short ch, 
  109.                                         short aKeyCode, EventInfo *info);
  110.     pascal struct TCommand *DoMenuCommand(CmdNumber aCmdNumber);
  111.     pascal void DoSetupMenus ();
  112.     pascal struct TCommand *DoMouseCommand(Point *theMouse, 
  113.                                     EventInfo *info, Point *hysteresis);
  114.     pascal Boolean DoSetCursor(Point localPoint, RgnHandle cursorRgn);
  115.     pascal void Draw(Rect *area);
  116. #ifdef qDebug
  117.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  118.                             Ptr fieldAddr, short fieldType, void *link), void *link);
  119. #endif
  120. };
  121.  
  122. class TColorCmd : public TCommand {
  123.  
  124. // friend class TTEDocument;
  125.  
  126. public:
  127.     TTEDocument    *fTEDocument;
  128.     TTextView        *fTextView;
  129.     int                fOldColorCmd, fNewColorCmd;    // menu command numbers
  130.     pascal void IColorCmd(int aCmdNumber, TTEDocument *itsDocument,
  131.                                         TTextView *itsView);
  132.     pascal void DoIt();
  133.     pascal void RedoIt();
  134.     pascal void UndoIt();
  135. #ifdef qDebug
  136.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  137.                          Ptr fieldAddr, short fieldType, void *link), void *link);
  138. #endif
  139. };
  140.  
  141.  
  142. class TSketcher : public TCommand {
  143.  
  144. public:
  145.     TTEDocument     *fTEDocument;
  146.     TTextView        *fTextView;
  147.     TBox            *fBox;            // the object being sketched
  148.     Rect            fBoxLocation;    // size of the Box being sketched
  149.     pascal void ISketcher(TTEDocument *itsDocument, TTextView *itsView);
  150.     pascal struct TCommand *TrackMouse(TrackPhase aTrackPhase,
  151.                             VPoint *anchorPoint, VPoint *previousPoint, 
  152.                             VPoint *nextPoint, Boolean mouseDidMove);
  153.     pascal void DoIt();
  154.     pascal void RedoIt();
  155.     pascal void UndoIt();
  156. #ifdef qDebug
  157.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  158.                             Ptr fieldAddr, short fieldType, void *link), void *link);
  159. #endif
  160. };
  161.  
  162.  
  163. class TDragger : public TCommand {
  164.  
  165. public:
  166.     TTEDocument     *fTEDocument;
  167.     TTextView        *fTextView;
  168.     TBox            *fBox;            // the object being dragged
  169.     Rect            oldLocation;    // initial location of object 
  170.     Rect            newLocation;    // new location of object 
  171.     Point            fDelta;            // offset moved    
  172.     PicHandle        fFeedbackPicture;    // support for Track feedback
  173.     Rect            fPictureBounds;        // idem
  174.     pascal void IDragger(TBox *itsBox, TTEDocument *itsDocument, TTextView *itsView);
  175.     pascal struct TCommand *TrackMouse(TrackPhase aTrackPhase,
  176.                             VPoint *anchorPoint, VPoint *previousPoint, 
  177.                             VPoint *nextPoint, Boolean mouseDidMove);
  178.     pascal void TrackFeedback(VPoint *anchorPoint, VPoint *nextPoint,
  179.                                 Boolean turnItOn, Boolean mouseDidMove);
  180.     pascal void DoIt();
  181.     pascal void RedoIt();
  182.     pascal void UndoIt();
  183. #ifdef qDebug
  184.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  185.                             Ptr fieldAddr, short fieldType, void *link), void *link);
  186. #endif
  187. };
  188.  
  189. class TSizer : public TCommand {
  190.  
  191. public:
  192.     TTEDocument     *fTEDocument;
  193.     TTextView        *fTextView;
  194.     TBox            *fBox;            // the object being dragged
  195.     Rect            oldLocation;    // initial location of object 
  196.     Rect            newLocation;    // new location of object 
  197.     Point            fStart;            // mouse pressed here
  198.     Point            fDelta;            // offset moved    
  199.     Boolean    pT,pB,pL,pR;    
  200.             // flags to indicate which coordinates to change    
  201.     pascal void ISizer(TBox *itsBox, TTEDocument *itsDocument, TTextView *itsView);
  202.     pascal struct TCommand *TrackMouse(TrackPhase aTrackPhase,
  203.                             VPoint *anchorPoint, VPoint *previousPoint, 
  204.                             VPoint *nextPoint, Boolean mouseDidMove);
  205.     pascal void TrackFeedback(VPoint *anchorPoint, VPoint *nextPoint,
  206.                                 Boolean turnItOn, Boolean mouseDidMove);
  207.     pascal void DoIt();
  208.     pascal void RedoIt();
  209.     pascal void UndoIt();
  210. #ifdef qDebug
  211.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  212.                             Ptr fieldAddr, short fieldType, void *link), void *link);
  213. #endif
  214. };
  215.  
  216.  
  217. class TTEDocument : public TDocument {
  218. public:
  219.     TPaletteView    *fPaletteView;
  220.     TTextView        *fTextView;
  221.     Handle            fTextHdl;            // text typed by user
  222.     int                fTextColorCmd;        // menu command number
  223.     TList            *fShapeList;        // list of Shapes to be drawn
  224.     pascal void ITEDocument();
  225.     pascal void AddShape(TBox *aBox); 
  226.     pascal void DeleteShape();
  227.     pascal void DoMakeWindows();
  228.     pascal void DoMakeViews(Boolean forPrinting);
  229.     pascal void DoNeedDiskSpace(long *dataForkBytes, long *rsrcForkBytes);
  230.     pascal void DoRead(short aRefNum, Boolean rsrcExists, Boolean forPrinting);
  231.     pascal void DoWrite(short aRefNum, Boolean makingCopy);
  232.     pascal void ForEachShapeDo(pascal void (*DoToItem)
  233.                 (TObject *item, void *DoToItem_Staticlink),void *DoToItem_Staticlink);
  234.     pascal void Free();
  235.     pascal void SetTextColorCmd(int theColorCmd);
  236.     pascal int  TextColorCmd();
  237. #ifdef qDebug
  238.     virtual pascal void Fields(pascal void (*DoToField) (StringPtr fieldName,
  239.                             Ptr fieldAddr, short fieldType, void *link), void *link);
  240. #endif
  241. };
  242.  
  243.  
  244. // --- global definitions ---
  245.  
  246. typedef pascal void (*DoToObject) (TObject *aObject, void *DoToObject_staticlink);
  247.  
  248. struct CalcDiskSpaceStruct {
  249.     long myDataForkBytes;
  250. };
  251.  
  252. struct DoToRectStruct {
  253.     int myRefNum;
  254. };
  255.  
  256. // support for dragging, JL 9/90
  257. struct FindBoxStruct {
  258.     Point theMouse;
  259.     TBox *myBox;
  260. };
  261.  
  262. // support for selections, JL 1/91
  263. struct SelectStruct {
  264.     TTextView *myTextView;
  265. };
  266.  
  267. // support for moves, JL 1/91
  268. struct MoveStruct {
  269.     Point delta;
  270. };
  271.  
  272. //
  273. // --- end of declarations ---
  274. //
  275.